package com.ymatou.iapi.proditem.service;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONObject;

import com.ymatou.iapi.productquery.compare.ProductQueryInterface;
import com.ymttest.business.YmatouAutoTestCall;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.MapUtil;

public class GetProductInfoByProductIdCall extends YmatouAutoTestCall
		implements
			ProductQueryInterface {
	private static String opurl = "api/Product/GetProductInfoByProductId";

	public GetProductInfoByProductIdCall() {
		//productquery		proditem  替换为java 站 url
		super(EnvSetup.getSystemUrl("productquery"), opurl, "GET", "JSON");
	}

	@Override
	public void addDefHeader() {
		//client.addHeader("Content-Type", "application/json");
	}

	public JSONObject callAndGetReturnData(String productId) {
		return callAndGetReturnData(MapUtil.hashMap("ProductId", productId,
				"NextActivityExpire", 100));
	}

	@Override
	public JSONObject search(List<String> productList) {
		return this.callAndGetReturnData(productList.get(0));
	}

	//获取某商品的返回信息
	public static JSONObject GetProductInfoByProductId(String sProductId)
			throws Exception {

		GetProductInfoByProductIdCall getProductInfoByProductIdCall = new GetProductInfoByProductIdCall();
		getProductInfoByProductIdCall.setData("ProductId=" + sProductId);
		getProductInfoByProductIdCall.callService();

		return new JSONObject(getProductInfoByProductIdCall.getReturnData());
	}

	public static void main(String[] args) {
		List<String> aList = new ArrayList<>();
		aList.add("3f31b27c-b810-423d-8057-ed22870db19c");

		//aList.add("5eb52acf-1d0c-4d60-99ee-49d4d55e1bf8");
		try {
			new GetProductInfoByProductIdCall()
					.GetProductInfoByProductId("96440ddb-70f7-4575-bd72-55ac66b3163d");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
